﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using Mongaba.Core;

namespace Mongaba
{
    public delegate void IpSelectedHandle();
    public partial class frmSelectIpAddress : Form
    {
        public frmSelectIpAddress()
        {
            InitializeComponent();
            this.Icon = Properties.Resources.Mongaba;
            lsbIpaddres.DataSource = Utilities.AvailableIps.Select(x => x.ToString()).ToArray();

 
        }

        
       

        private void frmSelectIpAddress_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Utilities.HostIp == null)
            {
                Application.Exit();
            }
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {

            if (lsbIpaddres.SelectedValue != null)
            {
                Utilities.HostIp = IPAddress.Parse(lsbIpaddres.SelectedValue.ToString());
                this.Close();
            }
            else
            {

            }
        }
    }
}
